
@include responsive($bp_medium){
	body.context-menu-open {
		.body {
			@include blur(10px);
		}
	}
}

.context-menu {
	position: fixed;
	z-index: 99;
	font-size: 13px;
	font-weight: 500;
	font-family: $font-family-alt;

	&__section {
		@include animate();
		overflow-y: scroll;

		&--submenu {
			z-index: 3;
			border-radius: 3px;
			transform: translateX(100%);
			opacity: 0;

			.context-menu {
				&__item {
					width: 100%;

					&--functional {
						color: colour('mid_grey');

						&:last-of-type {
							border-bottom: 1px solid colour('middle_grey');
						}
					}

					&__label {
						.icon {
							margin-bottom: 0.4em;
							padding-right: 10px;
							vertical-align: baseline;
						}
					}
				}
			}
		}

		&--items {
			opacity: 1;
			position: relative;
			z-index: 2;
		}
	}

	&__item {
		display: block;
		overflow-x: hidden;

		&--disabled {
			pointer-events: none;
			cursor: default;
			opacity: 0.5;
		}

		&__link {
			@include gradient_overlay(3px);
			cursor: pointer;
			display: block;
			padding: 9px 12px 8px;
			box-sizing: border-box;
			position: relative;
			text-decoration: none;
			color: inherit;

			&--inactive {
				cursor: default;
				opacity: 0.5;
				&:before {
					display: none;
				}
			}

			.notouch &:hover {
				&:before {
					opacity: 0.15;
				}
			}

			.notouch &:active {
				background: colour('turquoise');
				color: colour('white');
			}

			.icon {
				font-size: 12px;

				&.submenu-icon {
					display: inline-block;
					padding-top: 4px;
					margin-left: 10px;
					vertical-align: baseline
				}
			}
		}

		&--loader {
			text-align: center;
			margin-top: 50%;
		}
	}
	
	em {
		font-style: normal;

		&.context-menu__item:last-of-type {
			border-bottom: 1px solid colour('middle_grey');
		}
	}

	&__divider {
		height: 1px;
		padding: 0;
		margin: 0;
		background: colour('middle_grey');
		opacity: 0.5;
	}

	&--submenu-expanded {
		.context-menu {

			&__section {
				transform: translateX(-100%);
				opacity: 0;

				&--submenu {
					transform: translateX(0);
					opacity: 1;
				}
			}
		}
	}

	@include responsive(null, $bp_medium){
		width: 200px;
		overflow-x: hidden;
		border-radius: 3px;
		box-shadow: 2px 3px 6px rgba(0,0,0,0.2);

		@include theme('light') {
			background: colour('white');
		}

		@include theme('dark') {
			background: colour('grey');
		}

		&--closing {
			display: none;
		}

		&__section {
			background: none;
			overflow: visible;

			&--submenu {
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;

				@include theme('dark') {
					background: colour('grey');
				}

				@include theme('light') {
					background: colour('white');
				}
			}
		}

		&__title {
			display: none;
		}
	}

	@include responsive($bp_medium){
		@include fadein(0.1s, '100px');
		top: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		left: 0 !important;
		margin: 0 !important;
		text-align: center;
		overflow-y: auto;
		display: flex;
		flex-flow: column;
		flex-direction: column-reverse;

		&--closing {
			@include fadeout(0.2s, '100px');
		}

		&__background {
			position: absolute;
			top: 0;
			right: 0;
			bottom: 0;
			left: 0;
			z-index: 1;
			// background-image: linear-gradient(rgba(24,24,24,0) 0%, rgba(24,24,24,0.5) 20%);

			// @include theme('light') {
			// 	background-image: linear-gradient(rgba(255,255,255,0) 0%, rgba(255,255,255,0.5) 20%);
			// }
		}

		&__title {
			@include clearfix();
			color: colour('mid_grey');
			padding: 16px 22px;

			@include theme('light') {
				color: colour('darkest_grey');
			}

			.thumbnail {
				float: left;
				width: 36px;
				margin-right: 20px;
			}

			&__text {
				position: relative;
				z-index: 2;
				font-size: 1.2rem;
				font-weight: 800;
				padding-top: 8px;
			}

			&__type {
				display: none;
				position: relative;
				z-index: 2;
				opacity: 0.3;
				font-weight: 200;
				text-transform: capitalize;
			}

			&__deselect {
				font-size: 0.86em;
			}

			a {
				color: inherit;
			}
		}

		&__section {
			margin: 20% 10% 0 10%;
			padding-top: 10px;
			border-top-left-radius: 20px;
			border-top-right-radius: 20px;
			background: colour('white');
			box-shadow: 0 40px 40px rgba(0,0,0,0.75);
			overflow: visible;
	
			@include theme('dark') {
				background: colour('grey');
			}

			&--submenu {
				background: none;
				border-radius: 0;
				opacity: 0;
			}

			&--items {

				/**
				 * The following is for buttons automatically pulled from
				 * a page header, so we don't have classname control
				 **/
				.button {
					display: block;
					text-decoration: none;
					display: block;
					margin: 0;
					width: 100% !important;
					box-sizing: border-box;
					text-align: center;
					text-transform: none;
					font-weight: 700;
					font-size: 1.2rem;
					color: colour('white');
					background: none;
					transform: none;
					padding: 16px 22px;
					border: 0;
					border-radius: 3px;

					&,
					&:hover {
						box-shadow: none;
					}

					@include theme('light') {
						color: colour('darkest_grey');
					}

					.icon {
						display: none;
					}

					&:before {
						display: none !important;
					}

					&:focus,
					&:active {
						@include noanimate();
						color: colour('white') !important;
						background: colour('turquoise') !important;
					}
				}
			}
		}

		&__item {
			font-size: 1.2rem;
			font-weight: 800;
			opacity: 1;

			&__link {
				@include animate();
				padding: 16px 22px;
				box-sizing: border-box;

				@include theme('light') {
					color: colour('darkest_grey');
				}

				&:before {
					display: none !important;
				}

				&:focus,
				&:active {
					@include noanimate();
					color: colour('white') !important;
					background: colour('turquoise') !important;
				}
			}
		}
	}
}

.context-menu-trigger {
	position: relative;

	.actions & {
		font-size: 24px;
		padding: 2px 10px 1px;
	}

	.icon {
		pointer-events: none;
	}

	h4 &,
	h4 &:active {
		margin: -8px 0 0 10px;
	}

	@include responsive($bp_medium){
		padding: 12px;
	}
}
